package com.aliyun.messagemgt.repository;

import com.aliyun.messagemgt.converter.InterfaceLogConverter;
import com.aliyun.messagemgt.dto.InterfaceLog;
import com.aliyun.messagemgt.dto.query.InterFaceLogQuery;
import com.aliyun.messagemgt.domain.repository.InterfaceLogRepository;
import com.aliyun.messagemgt.entities.InterfaceLogEntity;
import com.aliyun.messagemgt.repository.mappers.InterfaceLogMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 */
@Service
public class InterfaceLogMyBatisRepository implements InterfaceLogRepository {

    @Autowired
    private InterfaceLogMapper interfaceLogMapper;

    @Override
    public List<InterfaceLog> queryInterfaceLogList(InterFaceLogQuery interFaceLog) {
        List<InterfaceLogEntity> interfaceLogEntityList = interfaceLogMapper.queryInterfaceLogList(interFaceLog);
        List<InterfaceLog> interfaceLogList = InterfaceLogConverter.INSTANCE.interfaceLogEntityList2interfaceLogList(interfaceLogEntityList);
        return interfaceLogList;
    }

    @Override
    public int countInterfaceLogList(InterFaceLogQuery interFaceLog) {
        return interfaceLogMapper.countInterfaceLogList(interFaceLog);
    }

    @Override
    public void insertSelective(List<InterfaceLog> interfaceLogList) {
        if (CollectionUtils.isNotEmpty(interfaceLogList)){
            interfaceLogMapper.insertSelective(interfaceLogList);
        }
    }
}
